package cn.smxy.ln.common.lang;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    //200正常,非200表示异常
    private String code;
    //
    private String msg;
    //数据
    private T data;


    public static Result succ(Object data) {
        Result m = new Result();
        m.setCode("200");
        m.setData(data);
        m.setMsg("操作成功");
        return m;
    }
    public static Result succ(String mess, Object data) {
        Result m = new Result();
        m.setCode("200");
        m.setData(data);
        m.setMsg(mess);
        return m;
    }
    public static Result fail(String mess) {
        Result m = new Result();
        m.setCode("400");
        m.setData(null);
        m.setMsg(mess);
        return m;
    }

    public static Result fail(String code, String mess, Object data) {
        Result m = new Result();
        m.setCode(code);
        m.setData(data);
        m.setMsg(mess);
        return m;
    }

    public static Result fail(String mess, Object data) {
        Result m = new Result();
        m.setCode("400");
        m.setData(data);
        m.setMsg(mess);
        return m;
    }
}



